const router = require('koa-router')() // 一边导入一边实例化
const result = require('../../config/result.js')
// const { regcheck,checking } = require('../../config/checking.js')
// 操作数据库的接口
const { getToken, Updateurl } = require('../../config/databaseapi.js')
// 注册接口
router.post('/editactivity', async (ctx) => {
	console.log('调用编辑党建活动信息接口')
	let {_id, activity_name, date, startTime, place, status, remark} = ctx.request.body;
	if(activity_name==='' || date==='' || startTime==='' || place===''){
		ctx.body = {msg:"修改失败",status:0}
	}else{
		let query = `db.collection("activity_info").where({_id:"${_id}"}).update({data:{activity_name:"${activity_name}",date:"${date}",startTime:"${startTime}",place:"${place}",status:"${status}",remark:"${remark}"}})`
		let res = await new getToken().posteve(Updateurl,query)
		if(res.errcode === 0){
			ctx.body = {msg:"修改成功",status:1}
		}else{
			ctx.body = {msg:"修改失败",status:0}
		}
	}

})

module.exports = router.routes()